import { Attr, AttrResData, AttrValueResPonseData} from "@/types/attr";
import http from "@/utils/request";
// 获取商品一级分类
export const getFirstAttrAPI=()=>{
    return http<any,AttrResData>({
        url:'/admin/product/getCategory1'
    })
}
// 获取商品二级分类
export const getSecondAttrAPI=(category1Id:number|string)=>{
    return http<any,AttrResData>({
        url:`/admin/product/getCategory2/${category1Id}`
    })
}
// 获取商品三级级分类
export const geThirdAttrAPI=(category2Id:number|string)=>{
    return http<any,AttrResData>({
        url:`/admin/product/getCategory3/${category2Id}`
    })
}
//获取全部属性接口
export const getallAttrAPI=(category1Id:number|string,category2Id:number|string,category3Id:number|string)=>{
    return http<any,AttrValueResPonseData>({
        url:`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
    })
}

//新增或修改已有属性
export const reqAddorUpadateAttr=(data:Attr)=>{
    return http<any,any>({
        url:'/admin/product/saveAttrInfo',
        method:'post',
        data
    })
}

//删除已有属性
export const delAttrAPI=(attrId:number|string)=>{
    return http<any,any>({
        url:`/admin/product/deleteAttr/${attrId}`,
        method:'delete'
    })
}